package com.bifrost.entity;


import javax.persistence.*;
import java.io.Serializable;

/**
 * @author rangf
 * @date 2018/5/31
 */
@Entity
@Table(name = "PROMOTION_CONSTRAINT",uniqueConstraints = {
        @UniqueConstraint(name = "CUST_PROM_PROD",columnNames ={"CUSTOMER_ID","PROMOTION_ID","PRODUCT_ID"} )
})
@NamedQuery(name = "PromotionConstraint.findAll", query = "SELECT pc FROM PromotionConstraint pc")
public class PromotionConstraint implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", unique = true, nullable = false)
    private Long Id;

    @Column(name = "QUANTITY")
    private Integer quantity = 0;

    @Column(name = "PRODUCT_ID")
    private Long productId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CUSTOMER_ID", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Customer customer;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "PROMOTION_ID", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Promotion promotion;

    public Long getId() {
        return Id;
    }

    public void setId(Long id) {
        Id = id;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public Promotion getPromotion() {
        return promotion;
    }

    public void setPromotion(Promotion promotion) {
        this.promotion = promotion;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }
}
